package huaweiod.first;

import java.util.*;

/**
 * 华为OD机试真题 Java 实现【预订酒店】【2022.11 Q4 新题】
 */
public class A_2023_38_HotelReservation {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();   // 最接近的酒店
        int x = in.nextInt();   // 心里预期价格
        int[] price = new int[n];
        LinkedList<Integer> list = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            price[i] = in.nextInt();
            list.add(price[i]);
        }
        list.sort((a, b) -> {
            int absA = Math.abs(a - x);
            int absB = Math.abs(b - x);
            if(absA == absB) {
                return a - b;
            } else {
                return absA < absB ? -1 : 1;
            }
        });
        StringJoiner sj = new StringJoiner(" ");
        for (int i = 0; i < k; i++) {
            sj.add(String.valueOf(list.get(i)));
        }
        System.out.println(sj);
    }
}
